home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieIMDB-es.py < prev    next >
Text File  |  2008-11-17  |  6KB  |  160 lines

  1. # -*- coding: iso-8859-15 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieIMDB-es.py 389 2006-07-29 18:43:35Z piotrek $'
  4.  
  5. # Copyright (c) 2006 Pedro D. Sßnchez
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27.  
  28. plugin_name        = 'IMDb-es'
  29. plugin_description    = 'Internet Movie Database Spanish'
  30. plugin_url        = 'spanish.imdb.com'
  31. plugin_language        = _('Spanish')
  32. plugin_author        = 'Pedro D. Sßnchez'
  33. plugin_author_email    = '<pedrodav@gmail.com>'
  34. plugin_version        = '0.2'
  35.  
  36. class Plugin(movie.Movie):
  37.     def __init__(self, id):
  38.         self.encode='iso-8859-15'
  39.         self.movie_id = id
  40.         self.url = "http://spanish.imdb.com/title/tt%s" % str(self.movie_id)
  41.  
  42.     def get_image(self):
  43.         tmp = string.find(self.page, 'a name="poster"')
  44.         if tmp == -1:        # poster not available
  45.             self.image_url = ''
  46.         else:
  47.             self.image_url = gutils.trim(self.page[tmp:], 'src="', '"')
  48.  
  49.     def get_o_title(self):
  50.         self.o_title = gutils.trim(self.page, '<strong class="title">', ' <small>')
  51.  
  52.     def get_title(self):
  53.         tmp = 0
  54.         tmpTot = 0
  55.         while (tmp <> -1):
  56.             auxTitle = ''
  57.             tmp = string.find(self.page[tmpTot:], '<i class="transl">')
  58.             if tmp <> -1:
  59.                 auxTitle = gutils.trim(self.page[tmpTot:], '<i class="transl">', '</i>')
  60.                 if string.find(auxTitle, '(Spain)') <> -1:
  61.                     auxTitle = string.replace(auxTitle, ' ', ' ')
  62.                     auxTitle = string.replace(auxTitle, ' (Argentina) ', '')
  63.                     auxTitle = string.replace(auxTitle, ' (Spain) ', '')
  64.                     auxTitle = string.replace(auxTitle, ' (Mexico) ', '')
  65.                     auxTitle = string.replace(auxTitle, '  [es]', '')
  66.                     tmp = -1
  67.                 tmpTot = tmpTot + tmp + 1
  68.         if auxTitle <> '':
  69.             self.title = auxTitle
  70.         else:
  71.             self.title = self.o_title
  72.  
  73.     def get_director(self):
  74.         self.director = gutils.trim(self.page,'Dirigida por</b><br>', '<br>')
  75.  
  76.     def get_plot(self):
  77.         self.plot = gutils.trim(self.page, '<b class="ch">Resumen', '<a href="/rg/title-tease/plot')
  78.         self.plot = gutils.after(self.plot, ':</b> ')
  79.  
  80.     def get_year(self):
  81.         self.year = gutils.trim(self.page, '<a href="/Sections/Years/', '</a>)</small>')
  82.         self.year = gutils.after(self.year, '">')
  83.  
  84.     def get_runtime(self):
  85.         self.runtime = gutils.trim(self.page, '<b class="ch">Duraci≤n:</b>', ' min')
  86.         if self.runtime == '':
  87.             self.runtime = gutils.trim(self.page, '<b class="ch">Duración:</b>', ' min')
  88.  
  89.     def get_genre(self):
  90.         self.genre = gutils.trim(self.page, '<a href="/Sections/Genres/', '<br>')
  91.         self.genre = gutils.after(self.genre, '/">')
  92.         self.genre = string.replace(self.genre, '(mßs)', '')
  93.         self.genre = string.replace(self.genre, '(más)', '')
  94.  
  95.     def get_cast(self):
  96.         self.cast = ''
  97.         self.cast = gutils.trim(self.page, 'Cast overview, first billed only:', '<a href="fullcredits">')
  98.         if (self.cast==''):
  99.             self.cast = gutils.trim(self.page, 'cast: ','<a href="fullcredits">')
  100.         self.cast = string.replace(self.cast, ' .... ', _(' as '))
  101.         self.cast = string.replace(self.cast, '</tr><tr>', "\n")
  102.         self.cast = string.replace(self.cast, '</tr><tr bgcolor="#FFFFFF">', "\n")
  103.         self.cast = string.replace(self.cast, '</tr><tr bgcolor="#F0F0F0">', "\n")
  104.         self.cast = string.strip(gutils.strip_tags(self.cast))
  105.  
  106.     def get_classification(self):
  107.         self.classification = gutils.trim(self.page, '<a href="/List?certificates=Spain:', '</a>')
  108.         self.classification = gutils.after(self.classification, '">Spain:')
  109.         #self.classification = gutils.trim(self.page, 'MPAA</a>:</b> ', '<br>')
  110.         #self.classification = ''
  111.  
  112.     def get_studio(self):
  113.         self.studio = ''
  114.  
  115.     def get_o_site(self):
  116.         self.o_site = ''
  117.  
  118.     def get_site(self):
  119.         self.site = "http://spanish.imdb.com/title/tt%s" % self.movie_id
  120.  
  121.     def get_trailer(self):
  122.         self.trailer = "http://spanish.imdb.com/title/tt%s/trailers" % self.movie_id
  123.  
  124.     def get_country(self):
  125.         self.country = gutils.trim(self.page, '<b class="ch">Paφs:</b>', '</a>')
  126.         if self.country == '':
  127.             self.country = gutils.trim(self.page, '<b class="ch">País:</b>', '</a>')
  128.         self.country = gutils.after(self.country, '/">')
  129.  
  130.     def get_rating(self):
  131.         self.rating = gutils.trim(self.page, '<b class="ch">Calificaci≤n de los usuarios:</b>', '/10</b> (')
  132.         if self.rating == '':
  133.             self.rating = gutils.trim(self.page, '<b class="ch">Calificación de los usuarios:</b>', '/10</b> (')
  134.         if self.rating:
  135.             self.rating = str(float(gutils.clean(self.rating)))
  136.  
  137. class SearchPlugin(movie.SearchMovie):
  138.  
  139.     def __init__(self):
  140.         self.original_url_search    = 'http://spanish.imdb.com/find?more=tt;q='
  141.         self.translated_url_search    = 'http://spanish.imdb.com/find?more=tt;q='
  142.         self.encode = 'iso-8859-15'
  143.  
  144.     def search(self,parent_window):
  145.         self.open_search(parent_window)
  146.         self.sub_search()
  147.         return self.page
  148.  
  149.     def sub_search(self):
  150.         self.page = gutils.trim(self.page, '</b> found the following results:', '<b>Suggestions For Improving Your Results</b>');
  151.         self.page = self.page.decode('iso-8859-15')
  152.  
  153.     def get_searches(self):
  154.         elements = string.split(self.page, '<li>')
  155.  
  156.         if (elements[0]<>''):
  157.             for element in elements:
  158.                 self.ids.append(gutils.trim(element, '/title/tt','/?fr='))
  159.                 self.titles.append(gutils.strip_tags(gutils.convert_entities(gutils.trim(element, ';fm=1">', '</li>'))))
  160.